﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Vici.CoolStorage;

namespace ViciTest
{
     public class DataSelect
    {
         public DataSelect()
         {
             CSConfig.SetDB(new CSDataProviderAccess("data.mdb"));
         }
         public string testget()
         {
             try
             {
                 string result;
                 
                 CSList<AppData> t = new CSList<AppData>();

                 if (t.Count>0)
                     result = "success";
                 else
                     result = "faild";
                 return result;
             }
             catch (Exception ex)
             {
                 return ex.Message;
             }
         }
         public string testadd()
         {
             try
             {
                 AppData a = AppData.New();
                 a.ID = 13;
                 a.AppName = "麻子";
                 return a.Save().ToString();
             }
             catch (Exception ex)
             {
                 return ex.Message;
             }
         }
         public string testdel(int id)
         {
             try
             {
                 AppData a = AppData.ReadSafe(id);
                 return a.Delete().ToString();
             }
             catch (Exception ex)
             {
                 return ex.Message;
             }
         }
         public string testupdate(AppData app)
         {
             try
             {
                 AppData a = AppData.Read(app.ID);
                 a.AppName = app.AppName;
                 return a.Save().ToString();
             }
             catch (Exception ex)
             {
                 return ex.Message;
             }
         }
    }
}
